﻿using System;
using System.Diagnostics;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using ModelValidation.AdjoinFireZone;

namespace ModelValidation.Commands
{
	[Transaction(TransactionMode.Manual)]
	public class CmdAdjoinFireZoneVer : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string messages, ElementSet elements)
		{
			WindowHandle windowHandle = null;
			if (windowHandle == null)
			{
				windowHandle = new WindowHandle(Process.GetCurrentProcess().MainWindowHandle);
			}
			bool bIsHorViewPlan = false;
			AdjoinFireZoneCheck adjoinFireZoneCheck = new AdjoinFireZoneCheck(cmdData, bIsHorViewPlan, windowHandle);
			if (!adjoinFireZoneCheck.GetTolViewPlan())
			{
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			if (!adjoinFireZoneCheck.SelectSetSprinkler())
			{
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			AdjoinFireZoneHorApplication.thisApp.ShowForm(cmdData, windowHandle, adjoinFireZoneCheck);
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
